home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Wayzata's Best of Shareware PC/Windows 1
/
Wayzata's Best of Shareware for PC-Windows - Release 1 - Wayzata Technology (1993).iso
/
mac
/
DOS
/
PROGRAMG
/
FORTHCMP
/
ROMGO.4TH
< prev
next >
Wrap
Text File
|
1992-03-30
|
3KB
|
91 lines
0 #IF
SAMPLE STARTUP CODE FOR ROMMABLE APPLICATIONS
COPYRIGHT 1985 (C) BY THOMAS ALMY. ALL RIGHTS RESERVED
Permission is granted to registered users of ForthCMP to sell or distribute
computer programs incorporating the compiled contents of this file.
MS is a trademark of Microsoft Corporation.
This file is for ROMABLE FILES. It will need to be modified
for particular situations. The generated file has a COM
extension, but is not executable under MS-DOS. Compile and
use the program UNLOAD to convert to INTEL HEX Format.
To run a rommable program, you must jump to the start of the ROM.
The segment location of the ROM is not important, the code is relocatable
To run the program as a separate data segment .COM DOS program, see
comments with *
#THEN
\ Fill in these with the appropriate values
HEX
\ * FOR DOS romoffset must be 100, ramseg needs to be set to a "safe"
\ * location near the top of the base memory address space, such as 8000
0 CONSTANT romoffset \ offset from start of segment for code ROM
1000 CONSTANT ramseg \ Segment RAM starts in.
0 CONSTANT ramoffset \ offset from start of segment for program RAM
1000 CONSTANT ramend \ offset from start of segment of end of RAM
\ use the following when a separate stack segment is desired
\ * FOR DOS, stackseg must be set to a safe location near the top of the
\ * base memory, but not conflicting with the data segment
2000 CONSTANT stackseg \ segment of stack RAM
1000 SEPSSEG \ states stack segment 1000 bytes long
\ Use the following to have the data segment initialized from ROM
\ * You will need to initialize if the DOS I/O functions are being used
\ * for development.
INITIALIZE
\ Back to common code
\ Size of return stack is third argument below. It get assigned to rssize.
ramoffset romoffset 100 ROMABLE \ sets up program format
ASM HEX FWD, ( skip the variables ) HEX DSEG
VARIABLE DP ( start free ram = HERE )
VARIABLE S0 ( top of stack )
VARIABLE R0 ( top of return stack )
VARIABLE BASE 0A BASE ! ( initialized at runtime )
initial? #IF CSEG CREATE SEGOFFSET 0 ,
#ELSE CSEG CREATE INITDP 0 , #THEN
THEN,
ramseg # AX MOV AX DS >SEG \ Set DS
SEPSSEG? #IF stackseg # AX MOV AX SS >SEG
pssize 10 * rssize - # SP MOV
pssize 10 * # BP MOV
#ELSE
AX SS >SEG ramend rssize - # SP MOV
ramend # BP MOV
#THEN
CLD
initial? #IF \ initialize it all
DS PUSHSEG ES POPSEG
AX CS <SEG CS: SEGOFFSET [] AX ADD AX DS >SEG \ source seg is end of code
SI SI XOR ramoffset # DI MOV \ OFFSETS
' DP [] CX MOV \ "here" as indicated in the ROM
DI CX SUB \ # bytes to move
REPZ BYTE MOVS \ move the bytes
ES PUSHSEG DS POPSEG
#ELSE \ we must at least initialize BASE and DP
0A # BASE [] MOV
CS: INITDP [] AX MOV AX DP [] MOV
#THEN
BP R0 [] MOV \ initialize R0
SP AX MOV AX DEC AX DEC AX S0 [] MOV \ initialize S0
0 0 IN/OUT NEED MAIN
CALL' MAIN ( call main program )
\ * For DOS, replace the following code with
\ * 4C # AX MOV 21 INT
CODE bye 0F4 C, END-CODE ( HALT )
FORTH DECIMAL DSEG